<?php
namespace app\admin\controller;

use think\annotation\route\Group;
use think\annotation\Route;
use think\annotation\route\Middleware;
use app\admin\middleware\CheckAdmin;
use think\facade\Db;

/**
 * 基础数据配置
 * Class Basic
 * @package app\admin\controller
 * @Group("basic")
 */
class Basic extends Base
{
    /**
     * 计划分类列表
     * @Route("plan_cate_list", method="POST")
     * @middleware({CheckAdmin::class})
     */
    public function planCateList()
    {
        $page = input('page', 1, 'intval');
        $pagesize = input('psize', 20, 'intval');
        $list = Db::name('plan_cate')
            ->order('id', 'desc')
            ->page($page, $pagesize)->select();
        $result['total'] = Db::name('plan_cate')->count();
        $result['data'] = $list;
        return json_ok($result);
    }

    /**
     * 添加计划分类
     * @Route("plan_cate_add", method="POST")
     * @middleware({CheckAdmin::class})
     */
    public function planCateAdd()
    {
        $data = input('post.');
        Db::name('plan_cate')->insert($data);
        return json_ok([], 10000, '操作成功');
    }

    /**
     * 修改计划分类
     * @Route("plan_cate_edit", method="POST")
     * @middleware({CheckAdmin::class})
     */
    public function planCateEdit()
    {
        $data = input('post.');
        Db::name('plan_cate')->where('id', $data['id'])->update($data);
        return json_ok([], 10000, '操作成功');
    }

    /**
     * 删除计划分类
     * @Route("plan_cate_del", method="POST")
     * @middleware({CheckAdmin::class})
     */
    public function planCateDel()
    {
        $id = input('id', 0, 'intval');
        Db::name('plan_cate')->where('id', $id)->delete();
        return json_ok([], 10000, '操作成功');
    }

    /**
     * 项目分类列表
     * @Route("project_cate_list", method="POST")
     * @middleware({CheckAdmin::class})
     */
    public function projectCateList()
    {
        $page = input('page', 1, 'intval');
        $pagesize = input('psize', 20, 'intval');
        $list = Db::name('project_cate')
            ->order('id', 'desc')
            ->page($page, $pagesize)->select();
        $result['total'] = Db::name('project_cate')->count();
        $result['data'] = $list;
        return json_ok($result);
    }

    /**
     * 添加项目分类
     * @Route("project_cate_add", method="POST")
     * @middleware({CheckAdmin::class})
     */
    public function projectCateAdd()
    {
        $data = input('post.');
        Db::name('project_cate')->insert($data);
        return json_ok([], 10000, '操作成功');
    }

    /**
     * 修改项目分类
     * @Route("project_cate_edit", method="POST")
     * @middleware({CheckAdmin::class})
     */
    public function projectCateEdit()
    {
        $data = input('post.');
        Db::name('project_cate')->where('id', $data['id'])->update($data);
        return json_ok([], 10000, '操作成功');
    }

    /**
     * 删除项目分类
     * @Route("project_cate_del", method="POST")
     * @middleware({CheckAdmin::class})
     */
    public function projectCateDel()
    {
        $id = input('id', 0, 'intval');
        Db::name('project_cate')->where('id', $id)->delete();
        return json_ok([], 10000, '操作成功');
    }

    /**
     * 专业列表
     * @Route("profession_list", method="POST")
     * @middleware({CheckAdmin::class})
     */
    public function professionList()
    {
        $page = input('page', 1, 'intval');
        $pagesize = input('psize', 20, 'intval');
        $list = Db::name('profession')
            ->order('id', 'desc')
            ->page($page, $pagesize)->select();
        $result['total'] = Db::name('profession')->count();
        $result['data'] = $list;
        return json_ok($result);
    }

    /**
     * 添加专业
     * @Route("profession_add", method="POST")
     * @middleware({CheckAdmin::class})
     */
    public function professionAdd()
    {
        $data = input('post.');
        Db::name('profession')->insert($data);
        return json_ok([], 10000, '操作成功');
    }

    /**
     * 修改专业
     * @Route("profession_edit", method="POST")
     * @middleware({CheckAdmin::class})
     */
    public function professionEdit()
    {
        $data = input('post.');
        Db::name('profession')->where('id', $data['id'])->update($data);
        return json_ok([], 10000, '操作成功');
    }

    /**
     * 删除专业
     * @Route("profession_del", method="POST")
     * @middleware({CheckAdmin::class})
     */
    public function professionDel()
    {
        $id = input('id', 0, 'intval');
        Db::name('profession')->where('id', $id)->delete();
        return json_ok([], 10000, '操作成功');
    }

    /**
     * 项目周期列表
     * @Route("project_cycle_list", method="POST")
     * @middleware({CheckAdmin::class})
     */
    public function projectCycleList()
    {
        $page = input('page', 1, 'intval');
        $pagesize = input('psize', 20, 'intval');
        $list = Db::name('project_cycle')
            ->order('id', 'desc')
            ->page($page, $pagesize)->select();
        $result['total'] = Db::name('project_cycle')->count();
        $result['data'] = $list;
        return json_ok($result);
    }

    /**
     * 添加项目周期
     * @Route("project_cycle_add", method="POST")
     * @middleware({CheckAdmin::class})
     */
    public function projectCycleAdd()
    {
        $data = input('post.');
        Db::name('project_cycle')->insert($data);
        return json_ok([], 10000, '操作成功');
    }

    /**
     * 修改项目周期
     * @Route("project_cycle_edit", method="POST")
     * @middleware({CheckAdmin::class})
     */
    public function projectCycleEdit()
    {
        $data = input('post.');
        Db::name('project_cycle')->where('id', $data['id'])->update($data);
        return json_ok([], 10000, '操作成功');
    }

    /**
     * 删除项目周期
     * @Route("project_cycle_del", method="POST")
     * @middleware({CheckAdmin::class})
     */
    public function projectCycleDel()
    {
        $id = input('id', 0, 'intval');
        Db::name('project_cycle')->where('id', $id)->delete();
        return json_ok([], 10000, '操作成功');
    }

    /**
     * 级别列表
     * @Route("level_list", method="POST")
     * @middleware({CheckAdmin::class})
     */
    public function levelList()
    {
        $page = input('page', 1, 'intval');
        $pagesize = input('psize', 20, 'intval');
        $list = Db::name('level')
            ->order('id', 'desc')
            ->page($page, $pagesize)->select();
        $result['total'] = Db::name('level')->count();
        $result['data'] = $list;
        return json_ok($result);
    }

    /**
     * 添加级别
     * @Route("level_add", method="POST")
     * @middleware({CheckAdmin::class})
     */
    public function levelAdd()
    {
        $data = input('post.');
        Db::name('level')->insert($data);
        return json_ok([], 10000, '操作成功');
    }

    /**
     * 修改级别
     * @Route("level_edit", method="POST")
     * @middleware({CheckAdmin::class})
     */
    public function levelEdit()
    {
        $data = input('post.');
        Db::name('level')->where('id', $data['id'])->update($data);
        return json_ok([], 10000, '操作成功');
    }

    /**
     * 删除级别
     * @Route("level_del", method="POST")
     * @middleware({CheckAdmin::class})
     */
    public function levelDel()
    {
        $id = input('id', 0, 'intval');
        Db::name('level')->where('id', $id)->delete();
        return json_ok([], 10000, '操作成功');
    }

    /**
     * 支持区域列表
     * @Route("support_area_list", method="POST")
     * @middleware({CheckAdmin::class})
     */
    public function supportAreaList()
    {
        $page = input('page', 1, 'intval');
        $pagesize = input('psize', 20, 'intval');
        $list = Db::name('support_area')
            ->order('id', 'desc')
            ->page($page, $pagesize)->select();
        $result['total'] = Db::name('support_area')->count();
        $result['data'] = $list;
        return json_ok($result);
    }

    /**
     * 添加支持区域
     * @Route("support_area_add", method="POST")
     * @middleware({CheckAdmin::class})
     */
    public function supportAreaAdd()
    {
        $data = input('post.');
        Db::name('support_area')->insert($data);
        return json_ok([], 10000, '操作成功');
    }

    /**
     * 修改支持区域
     * @Route("support_area_edit", method="POST")
     * @middleware({CheckAdmin::class})
     */
    public function supportAreaEdit()
    {
        $data = input('post.');
        Db::name('support_area')->where('id', $data['id'])->update($data);
        return json_ok([], 10000, '操作成功');
    }

    /**
     * 删除支持区域
     * @Route("support_area_del", method="POST")
     * @middleware({CheckAdmin::class})
     */
    public function supportAreaDel()
    {
        $id = input('id', 0, 'intval');
        Db::name('support_area')->where('id', $id)->delete();
        return json_ok([], 10000, '操作成功');
    }
}